<html>
<head><meta charset="utf-8"><title>LLVM 13 · t-compiler/wg-llvm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/index.html">t-compiler/wg-llvm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html">LLVM 13</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="247141068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/247141068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#247141068">(Jul 25 2021 at 19:32)</a>:</h4>
<p>I've started looking into the LLVM 13 upgrade. First two issues are <a href="https://bugs.llvm.org/show_bug.cgi?id=51207">https://bugs.llvm.org/show_bug.cgi?id=51207</a> and <a href="https://bugs.llvm.org/show_bug.cgi?id=51210">https://bugs.llvm.org/show_bug.cgi?id=51210</a>.</p>



<a name="247143174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/247143174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#247143174">(Jul 25 2021 at 20:26)</a>:</h4>
<p>And <a href="https://bugs.llvm.org/show_bug.cgi?id=51211">https://bugs.llvm.org/show_bug.cgi?id=51211</a>.</p>



<a name="247520852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/247520852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#247520852">(Jul 28 2021 at 21:39)</a>:</h4>
<p>PR: <a href="https://github.com/rust-lang/rust/pull/87570">https://github.com/rust-lang/rust/pull/87570</a></p>



<a name="247794822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/247794822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#247794822">(Jul 31 2021 at 09:07)</a>:</h4>
<p>Off to a good start: <a href="https://reviews.llvm.org/D107216">https://reviews.llvm.org/D107216</a></p>



<a name="247795059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/247795059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#247795059">(Jul 31 2021 at 09:14)</a>:</h4>
<p>Not sure what to do with that. Guess we could stop using LLVM to embed bitcode and instead do that via the object crate, same as we do with metadata in rlibs. Would lose LTO on architectures not supported by the object crate, but it seems to have good coverage.</p>



<a name="247795364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/247795364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#247795364">(Jul 31 2021 at 09:24)</a>:</h4>
<p>Looking at it's API, it doesn't look like the object crate is particularly great at modifying existing object files. Need to explicitly copy everything over correctly.</p>



<a name="247795538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/247795538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#247795538">(Jul 31 2021 at 09:30)</a>:</h4>
<p>Don't object files contain either compiled code <strong>or</strong> bitcode?</p>



<a name="247795563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/247795563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#247795563">(Jul 31 2021 at 09:31)</a>:</h4>
<p>Never mind.</p>



<a name="247795614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/247795614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#247795614">(Jul 31 2021 at 09:32)</a>:</h4>
<p>rustc can include both. The bitcode is used for LTO, the compiled code is used otherwise.</p>



<a name="247813010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/247813010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#247813010">(Jul 31 2021 at 16:29)</a>:</h4>
<p>I think it's a reasonable way forward. In my memory we recently moved to object crate for archive reading and parsing too.</p>



<a name="247818785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/247818785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#247818785">(Jul 31 2021 at 18:45)</a>:</h4>
<p>Correct. There is also a PR to use it for creating metadata object files.</p>



<a name="247820081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/247820081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#247820081">(Jul 31 2021 at 19:15)</a>:</h4>
<p>Can you point me to that PR? I couldn't find it.</p>



<a name="247820980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/247820980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#247820980">(Jul 31 2021 at 19:39)</a>:</h4>
<p>I forgot it was already merged: <a href="https://github.com/rust-lang/rust/pull/84449">https://github.com/rust-lang/rust/pull/84449</a></p>



<a name="248667251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/248667251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#248667251">(Aug 06 2021 at 20:54)</a>:</h4>
<p>Anyone have an idea on what could cause <a href="https://github.com/rust-lang/rust/pull/87570#issuecomment-890152637">https://github.com/rust-lang/rust/pull/87570#issuecomment-890152637</a> ?</p>



<a name="248679683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/248679683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#248679683">(Aug 06 2021 at 23:23)</a>:</h4>
<p><span class="user-mention" data-user-id="133224">@Nikita Popov</span> do you know if <code>rustc test.rs</code> is using BFD or LLD?</p>



<a name="248679958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/248679958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#248679958">(Aug 06 2021 at 23:27)</a>:</h4>
<p>My guess is that it's related to the weird section name we use: <a href="https://github.com/rust-lang/rust/blob/5ad7389bdd1abe7d2c6f73a233af1a7a69e96285/library/std/src/sys/unix/args.rs#L109">https://github.com/rust-lang/rust/blob/5ad7389bdd1abe7d2c6f73a233af1a7a69e96285/library/std/src/sys/unix/args.rs#L109</a></p>



<a name="248679981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/248679981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#248679981">(Aug 06 2021 at 23:27)</a>:</h4>
<p>the standard section name is <code>.init_array</code></p>



<a name="248680289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/248680289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#248680289">(Aug 06 2021 at 23:31)</a>:</h4>
<p>Ah, I think I've found it</p>



<a name="248680360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/248680360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#248680360">(Aug 06 2021 at 23:32)</a>:</h4>
<p>The default LD BFD linker script will match any section starting with <code>.init_array</code>: <a href="https://github.com/alisw/gcc-toolchain/blob/61a1fb6ff726551e5176ff72f903b996cbbf5d22/binutils-2.25.1/ld/scripttempl/elf.sc#L241-L242">https://github.com/alisw/gcc-toolchain/blob/61a1fb6ff726551e5176ff72f903b996cbbf5d22/binutils-2.25.1/ld/scripttempl/elf.sc#L241-L242</a></p>



<a name="248680383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/248680383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#248680383">(Aug 06 2021 at 23:33)</a>:</h4>
<p>However, LD gold does not use a linker script to place <code>__init_array_start</code> and <code>__init_array_end</code> - it appears to explicitly lookup the section <code>.init_array</code>: <a href="https://github.com/alisw/gcc-toolchain/blob/61a1fb6ff726551e5176ff72f903b996cbbf5d22/binutils-2.25.1/gold/defstd.cc#L63-L86">https://github.com/alisw/gcc-toolchain/blob/61a1fb6ff726551e5176ff72f903b996cbbf5d22/binutils-2.25.1/gold/defstd.cc#L63-L86</a></p>



<a name="248680489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/248680489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#248680489">(Aug 06 2021 at 23:35)</a>:</h4>
<p>I have no idea how that ever worked under Gold</p>



<a name="248680805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/248680805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#248680805">(Aug 06 2021 at 23:40)</a>:</h4>
<p>I may be mistaken about what gold is doing - on the latest nightly, passing <code>-Zpre-link-args="-fuse-ld=gold"</code> results in <code>_ZN3std3sys4unix4args3imp15ARGV_INIT_ARRAY</code> ending up between <code>__init_array_start</code> and <code>__init_array_end</code></p>



<a name="248681132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/248681132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#248681132">(Aug 06 2021 at 23:47)</a>:</h4>
<p>I was in fact incorrect - gold does have special handling for '.init_array.'sections: <a href="https://github.com/bminor/binutils-gdb/blob/8179e388b60acc6ac35b40cd154f8d56234d1c3b/gold/layout.cc#L1253">https://github.com/bminor/binutils-gdb/blob/8179e388b60acc6ac35b40cd154f8d56234d1c3b/gold/layout.cc#L1253</a></p>



<a name="248705375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/LLVM%2013/near/248705375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/LLVM.2013.html#248705375">(Aug 07 2021 at 08:45)</a>:</h4>
<p>Just to be sure, I changed the section name to just <code>.init_array</code>, but the result is the same.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>